//! The basic memory function uses rtthread API

#[alloc_error_handler]
fn foo(_: core::alloc::Layout) -> ! {
    panic!("OOM!");
}

use core::alloc::{GlobalAlloc, Layout};
use crate::base::rttbase_malloc;
use crate::base::rttbase_free;

pub struct RttAlloc;

unsafe impl GlobalAlloc for RttAlloc {
    unsafe fn alloc(&self, layout:Layout) -> *mut u8 {
        rttbase_malloc(layout.size() as usize)
    }

    unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
        rttbase_free(ptr)
    }
}